<div class="layui-form" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <form >
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <script type="text/html" template>
                    <input type="text" name="account" value="" lay-verify="required"
                           placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <script type="text/html" template>
                    <input type="text" name="mobile" value="" lay-verify="phone"
                           placeholder="请输入手机号" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <script type="text/html" template>
                    <select name="roleId" id="role">
                        <option value=''>请选择</option>
                    </select>
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <script type="text/html" template>
                    <input type="checkbox" lay-filter="switch" name="check" lay-skin="switch" lay-text="启用|禁用">
                </script>
            </div>
        </div>
    </form>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-user-add-submit" value="确认"
                   class="layui-btn layui-btn-fluid">
        </div>
    </div>
</div>

<script>
    layui.use(['admin', 'form', 'setter'], function () {
        var $ = layui.$
            , admin = layui.admin
            , form = layui.form
            , setter = layui.setter

        var apiUrl = setter.apiUrl;

        admin.req({
            url: apiUrl + '/mapi/permission/r/list' //实际使用请改成服务端真实接口
            , method: 'post'
            , data: JSON.stringify({})
            , done: function (response) {
                if (response.code === 0) {
                    var data = response.data.list;
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                        html += "<option value=" + data[i]["id"] + ">" + data[i]["name"] + "</option>";
                    }
                    $("#role").append(html);
                    form.render('select');
                }
            }
        });

    });


</script>